﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.sim {
    import Engine.Classes.*;
    import flash.events.*;
    import Classes.*;
    import Classes.util.*;
    import Classes.effects.*;
    import com.greensock.*;
    import Classes.actions.*;

    public class FranchiseShockwave extends ConsumerShockwave {

        public function FranchiseShockwave(_arg1:MapResource, _arg2:Number, _arg3:Number, _arg4:Function=null, _arg5:Function=null, _arg6:Boolean=false, _arg7:uint=0xFFAA00){
            super(_arg1, _arg2, _arg3, _arg4, _arg5, _arg6, _arg7);
        }
        override protected function onEnterFrame(_arg1:Event):void{
            var candidate:* = null;
            var shockWave:* = null;
            var fadeout:* = NaN;
            var event:* = _arg1;
            if (m_origin == null){
                stop();
                return;
            };
            updateVisuals();
            var checker:* = function (_arg1:WorldObject):Boolean{
                if (((!((_arg1 is NPC))) || (((m_origin as Business) == null)))){
                    return (false);
                };
                var _local2:NPC = (_arg1 as NPC);
                return (((((((((!((_local2 == null))) && (!((m_seenNpcs == null))))) && ((m_seenNpcs[_local2] == null)))) && ((_local2.getPosition().subtract(m_center).length() <= m_tileRadius)))) && (!((_local2 is DummyNPC)))));
            };
            var freshmeat:* = Global.world.getObjectsByPredicate(checker);
            if ((((freshmeat.length > 0)) && (!((m_npcConsumer == null))))){
                for each (candidate in freshmeat) {
                    m_seenNpcs[candidate] = true;
                    shockWave = new ConsumerShockwave(candidate, (m_velocity / NPC_SHOCKWAVE_VELOCITY_FACTOR), NPC_SHOCKWAVE_RADIUS, null, null, true);
                    candidate.addAnimatedEffect(EffectType.SHORT_GLOW);
                    TimerUtil.callLater(function ():void{
                        candidate.addAnimatedEffect(EffectType.COIN);
                    }, 500);
                    if ((((candidate is Peep)) && ((candidate as Peep).isFranchiseFreebie))){
                        TimerUtil.callLater(function ():void{
                            candidate.getStateMachine().removeAllStates();
                            candidate.getStateMachine().addActions(new ActionDie(candidate));
                        }, 800);
                    };
                    shockWave.start();
                };
                m_npcConsumer(freshmeat);
            };
            if (((m_fadeHalfway) && ((m_tileRadius >= (m_maxRadius / 2))))){
                fadeout = 1.5;
                TweenLite.to(m_animation, fadeout, {alpha:0});
                m_fadeHalfway = false;
            };
            if (m_tileRadius >= m_maxRadius){
                if (m_endCallback != null){
                    m_endCallback();
                } else {
                    stop();
                };
            };
        }

    }
}//package Classes.sim 
